package com.ywwl.controller;

import com.alibaba.fastjson.JSON;
import com.ywwl.domain.table.BasicsCustomer;
import com.ywwl.service.CustomerService;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/customer")
public class CustomerController {
    private static Logger logger = Logger.getLogger(CustomerController.class);

    @Resource
    private CustomerService customerService;

    @ResponseBody
    @RequestMapping(value = "/find", method = RequestMethod.GET)
    public BasicsCustomer find(HttpServletRequest request) throws Exception {
        int id = Integer.parseInt(request.getParameter("id"));

        BasicsCustomer customer = this.customerService.find(id);

        logger.info("用户信息：" + JSON.toJSONString(customer));
        return customer;
    }
}
